<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Math数学计算</title>
</head>
<body>
    <script>
        // 取最大值
        console.log(Math.max(2,3,4,6));

        // 取最小值
        console.log(Math.min(2,3,4,6));


        // 取数组中的最大/小值
        let arr = [324,67,7647,9867];
        console.log(Math.max.apply(null,arr));
        console.log(Math.min.apply(null,arr));


        // 向上取整
        console.log(Math.ceil(5.01));

        // 向下取整
        console.log(Math.floor(5.99));


        // 四舍五入，保留2位小数
        let a = 453.546;
        console.log(a.toFixed(2));

        // 四舍五入，保留整数
        console.log(a.toFixed(0));
        console.log(Math.round(a));
    </script>
</body>
</html>